package vno.sci.window
{
	import fl.controls.Button;
	import fl.controls.Label;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.filters.BitmapFilter;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	import org.aswing.ASFont;
	import org.aswing.AsWingManager;
	import org.aswing.JButton;
	
	import vno.sci.event.MonologEvent;

	/**
	 * 两个按钮被点后都放出MonologEvent.CLICK事件
	 * 可能用event.id区别，左边的按钮event.id = 0; 右边的event.id = 1;
	 * @author scinart
	 */	
	public class GlowMessageBox extends Sprite
	{
		[Embed(source="c:/windows/fonts/ComicMaid.ttf", embedAsCFF="false", fontName="ComicMaid", mimeType="application/x-font",
unicodeRange="U+522B, U+5973, U+6027, U+62E9, U+7537, U+8272, U+89D2, U+8BF7, U+9009")]

		public static const ComicMaid:Class;
		
		public var buttonHeight:int = 30;
		public var titleHeight:int = 0;
		
		public var text:Label = new Label();
		

		public var prevBtn:JButton = new JButton();
		public var nextBtn:JButton = new JButton();
				
		public var windowWidth:int = 300;
		public var windowHeight:int = 200;
		
		
		public function GlowMessageBox(color:uint = 0x33CCFF)
		{
//			AsWingManager.initAsStandard(this);
			
			text.htmlText = "<font color='#000000' face='ComicMaid' size='48'>请选择角色性别</font>"
			
			this.addChild(text);
				
			// 布局专区
			text.setSize(400,100);
			text.x = 13;
			text.y = 30;
			prevBtn.x = 20;
			prevBtn.y = 150;
			
			nextBtn.x = 190;
			nextBtn.y = 150;
			// end 布局专区
			
			var theASFont:ASFont =new ASFont("ComicMaid", 36, true,false,false,true);
			
			prevBtn.setFont(theASFont);
			prevBtn.setText("男");
			prevBtn.setSizeWH(150,50);
			nextBtn.setFont(theASFont);
			nextBtn.setText("女");
			nextBtn.setSizeWH(150,50);
			
			
			/*
			var tf:TextFormat = new TextFormat("ComicMaid",36,0x000000,true);
			prevBtn.label = "男";
			prevBtn.setStyle("textFormat", tf);
			prevBtn.setSize(150,50);
			prevBtn.setStyle("backgroundColor", 0x44DDEE);
			nextBtn.label = "女";
			nextBtn.setStyle("textFormat", tf);
			nextBtn.setSize(150,50);
			*/
			
			
			prevBtn.addEventListener(MouseEvent.CLICK,handlePrev);
			nextBtn.addEventListener(MouseEvent.CLICK,handleNext);
			
			this.graphics.beginFill(0xEEEEEE,0.8);
			this.graphics.drawRect(0,0,360,240);
			this.graphics.endFill();
			var filtersArray:Array = new Array();
			//var color:Number = 0x00CCFF;
			var alpha:Number = 0.8;
			var blurX:Number = 35;
			var blurY:Number = 35;
			var strength:Number = 2;
			var inner:Boolean = false;
			var knockout:Boolean = false;
			var quality:Number = BitmapFilterQuality.HIGH;
			
			var flt:BitmapFilter = new GlowFilter(color,
													alpha,
													blurX,
													blurY,
													strength,
													quality,
													inner,
													knockout);
			
			filtersArray.push(flt);
			filters = filtersArray;
			
			this.addChild(prevBtn);
			this.addChild(nextBtn);
			
			this.x = 50;
			this.y = 50;
		}
		
		
		protected function handlePrev(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			event.stopImmediatePropagation();
			dispatchEvent(new MonologEvent(0,MonologEvent.CLICK, event.bubbles, event.cancelable));
		}
		
		protected function handleNext(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			event.stopImmediatePropagation();
			dispatchEvent(new MonologEvent(1,MonologEvent.CLICK,event.bubbles,event.cancelable));
		}
		
		public function close():void
		{
			try
			{
				this.visible = false;
				this.parent.removeChild(this);
			}
			catch(e:Error)
			{
				
			}
		}
	}
}